﻿
namespace ATA.Windows.Forms
{
	/// <summary>
	/// abstract ChietKhau typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class ChietKhauDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<ChietKhauDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.ChietKhau _currentChietKhau = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxChietKhauDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxChietKhauErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxChietKhauBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the ChietKhauId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxChietKhauIdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the StartDate property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxStartDateDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the EndDate property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxEndDateDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the DieuKienGiamGiaId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxDieuKienGiamGiaIdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the GhiChu property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxGhiChuDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the LastUpdate property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxLastUpdateDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the UpdateBy property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxUpdateByDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Header property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxHeaderDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the NhomKhachHangId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxNhomKhachHangIdDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
				
		private Entities.TList<Entities.NhomKhachHang> _NhomKhachHangIdList;
		
		/// <summary> 
		/// The list of selectable NhomKhachHang
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.NhomKhachHang> NhomKhachHangIdList
		{
			get {return this._NhomKhachHangIdList;}
			set 
			{
				this._NhomKhachHangIdList = value;
				this.uxNhomKhachHangIdDataGridViewColumn.DataSource = null;
				this.uxNhomKhachHangIdDataGridViewColumn.DataSource = this._NhomKhachHangIdList;
			}
		}
		
		private bool _allowNewItemInNhomKhachHangIdList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of NhomKhachHang
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInNhomKhachHangIdList
		{
			get { return _allowNewItemInNhomKhachHangIdList;}
			set
			{
				this._allowNewItemInNhomKhachHangIdList = value;
				this.uxNhomKhachHangIdDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
				
		private Entities.TList<Entities.DieuKienGiamGia> _DieuKienGiamGiaIdList;
		
		/// <summary> 
		/// The list of selectable DieuKienGiamGia
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.DieuKienGiamGia> DieuKienGiamGiaIdList
		{
			get {return this._DieuKienGiamGiaIdList;}
			set 
			{
				this._DieuKienGiamGiaIdList = value;
				this.uxDieuKienGiamGiaIdDataGridViewColumn.DataSource = null;
				this.uxDieuKienGiamGiaIdDataGridViewColumn.DataSource = this._DieuKienGiamGiaIdList;
			}
		}
		
		private bool _allowNewItemInDieuKienGiamGiaIdList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of DieuKienGiamGia
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInDieuKienGiamGiaIdList
		{
			get { return _allowNewItemInDieuKienGiamGiaIdList;}
			set
			{
				this._allowNewItemInDieuKienGiamGiaIdList = value;
				this.uxDieuKienGiamGiaIdDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.ChietKhau> _ChietKhauList;
				
		/// <summary> 
		/// The list of ChietKhau to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.ChietKhau> ChietKhauList
		{
			get {return this._ChietKhauList;}
			set
			{
				this._ChietKhauList = value;
				this.uxChietKhauBindingSource.DataSource = null;
				this.uxChietKhauBindingSource.DataSource = value;
				this.uxChietKhauDataGridView.DataSource = null;
				this.uxChietKhauDataGridView.DataSource = this.uxChietKhauBindingSource;				
				//this.uxChietKhauBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxChietKhauBindingSource_ListChanged);
				this.uxChietKhauBindingSource.CurrentItemChanged += new System.EventHandler(OnChietKhauBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnChietKhauBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentChietKhau = uxChietKhauBindingSource.Current as Entities.ChietKhau;
			
			if (_currentChietKhau != null)
			{
				_currentChietKhau.Validate();
			}
			//_ChietKhau.Validate();
			OnCurrentEntityChanged();
		}

		//void uxChietKhauBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.ChietKhau"/> instance.
		/// </summary>
		public Entities.ChietKhau SelectedChietKhau
		{
			get {return this._currentChietKhau;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxChietKhauDataGridView.VirtualMode;}
			set
			{
				this.uxChietKhauDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxChietKhauDataGridView.AllowUserToAddRows;}
			set {this.uxChietKhauDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxChietKhauDataGridView.AllowUserToDeleteRows;}
			set {this.uxChietKhauDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxChietKhauDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxChietKhauDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="ChietKhauDataGridViewBase"/> class.
		/// </summary>
		public ChietKhauDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxChietKhauDataGridView = new System.Windows.Forms.DataGridView();
			this.uxChietKhauBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxChietKhauErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxChietKhauIdDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxStartDateDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxEndDateDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxDieuKienGiamGiaIdDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxGhiChuDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxLastUpdateDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxUpdateByDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxHeaderDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNhomKhachHangIdDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			//this.uxNhomKhachHangIdBindingSource = new NhomKhachHangBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxNhomKhachHangIdBindingSource)).BeginInit();
			//this.uxDieuKienGiamGiaIdBindingSource = new DieuKienGiamGiaBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxDieuKienGiamGiaIdBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxChietKhauErrorProvider
			// 
			this.uxChietKhauErrorProvider.ContainerControl = this;
			this.uxChietKhauErrorProvider.DataSource = this.uxChietKhauBindingSource;						
			// 
			// uxChietKhauDataGridView
			// 
			this.uxChietKhauDataGridView.AutoGenerateColumns = false;
			this.uxChietKhauDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxChietKhauDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxChietKhauIdDataGridViewColumn,
		this.uxStartDateDataGridViewColumn,
		this.uxEndDateDataGridViewColumn,
		this.uxDieuKienGiamGiaIdDataGridViewColumn,
		this.uxGhiChuDataGridViewColumn,
		this.uxLastUpdateDataGridViewColumn,
		this.uxUpdateByDataGridViewColumn,
		this.uxHeaderDataGridViewColumn,
		this.uxNhomKhachHangIdDataGridViewColumn			});
			this.uxChietKhauDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxChietKhauDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxChietKhauDataGridView.Name = "uxChietKhauDataGridView";
			this.uxChietKhauDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxChietKhauDataGridView.TabIndex = 0;	
			this.uxChietKhauDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxChietKhauDataGridView.EnableHeadersVisualStyles = false;
			this.uxChietKhauDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnChietKhauDataGridViewDataError);
			this.uxChietKhauDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnChietKhauDataGridViewCellValueNeeded);
			this.uxChietKhauDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnChietKhauDataGridViewCellValuePushed);
			
			//
			// uxChietKhauIdDataGridViewColumn
			//
			this.uxChietKhauIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxChietKhauIdDataGridViewColumn.DataPropertyName = "ChietKhauId";
			this.uxChietKhauIdDataGridViewColumn.HeaderText = "ChietKhauId";
			this.uxChietKhauIdDataGridViewColumn.Name = "uxChietKhauIdDataGridViewColumn";
			this.uxChietKhauIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxChietKhauIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxChietKhauIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxStartDateDataGridViewColumn
			//
			this.uxStartDateDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxStartDateDataGridViewColumn.DataPropertyName = "StartDate";
			this.uxStartDateDataGridViewColumn.HeaderText = "StartDate";
			this.uxStartDateDataGridViewColumn.Name = "uxStartDateDataGridViewColumn";
			this.uxStartDateDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxStartDateDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxStartDateDataGridViewColumn.ReadOnly = false;		
			//
			// uxEndDateDataGridViewColumn
			//
			this.uxEndDateDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxEndDateDataGridViewColumn.DataPropertyName = "EndDate";
			this.uxEndDateDataGridViewColumn.HeaderText = "EndDate";
			this.uxEndDateDataGridViewColumn.Name = "uxEndDateDataGridViewColumn";
			this.uxEndDateDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxEndDateDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxEndDateDataGridViewColumn.ReadOnly = false;		
			//
			// uxDieuKienGiamGiaIdDataGridViewColumn
			//
			this.uxDieuKienGiamGiaIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDieuKienGiamGiaIdDataGridViewColumn.DataPropertyName = "DieuKienGiamGiaId";
			this.uxDieuKienGiamGiaIdDataGridViewColumn.HeaderText = "DieuKienGiamGiaId";
			this.uxDieuKienGiamGiaIdDataGridViewColumn.Name = "uxDieuKienGiamGiaIdDataGridViewColumn";
			this.uxDieuKienGiamGiaIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDieuKienGiamGiaIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDieuKienGiamGiaIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxGhiChuDataGridViewColumn
			//
			this.uxGhiChuDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxGhiChuDataGridViewColumn.DataPropertyName = "GhiChu";
			this.uxGhiChuDataGridViewColumn.HeaderText = "GhiChu";
			this.uxGhiChuDataGridViewColumn.Name = "uxGhiChuDataGridViewColumn";
			this.uxGhiChuDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxGhiChuDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxGhiChuDataGridViewColumn.ReadOnly = false;		
			//
			// uxLastUpdateDataGridViewColumn
			//
			this.uxLastUpdateDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxLastUpdateDataGridViewColumn.DataPropertyName = "LastUpdate";
			this.uxLastUpdateDataGridViewColumn.HeaderText = "LastUpdate";
			this.uxLastUpdateDataGridViewColumn.Name = "uxLastUpdateDataGridViewColumn";
			this.uxLastUpdateDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxLastUpdateDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxLastUpdateDataGridViewColumn.ReadOnly = false;		
			//
			// uxUpdateByDataGridViewColumn
			//
			this.uxUpdateByDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxUpdateByDataGridViewColumn.DataPropertyName = "UpdateBy";
			this.uxUpdateByDataGridViewColumn.HeaderText = "UpdateBy";
			this.uxUpdateByDataGridViewColumn.Name = "uxUpdateByDataGridViewColumn";
			this.uxUpdateByDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxUpdateByDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxUpdateByDataGridViewColumn.ReadOnly = false;		
			//
			// uxHeaderDataGridViewColumn
			//
			this.uxHeaderDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxHeaderDataGridViewColumn.DataPropertyName = "Header";
			this.uxHeaderDataGridViewColumn.HeaderText = "Header";
			this.uxHeaderDataGridViewColumn.Name = "uxHeaderDataGridViewColumn";
			this.uxHeaderDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxHeaderDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxHeaderDataGridViewColumn.ReadOnly = false;		
			//
			// uxNhomKhachHangIdDataGridViewColumn
			//
			this.uxNhomKhachHangIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNhomKhachHangIdDataGridViewColumn.DataPropertyName = "NhomKhachHangId";
			this.uxNhomKhachHangIdDataGridViewColumn.HeaderText = "NhomKhachHangId";
			this.uxNhomKhachHangIdDataGridViewColumn.Name = "uxNhomKhachHangIdDataGridViewColumn";
			this.uxNhomKhachHangIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNhomKhachHangIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNhomKhachHangIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxNhomKhachHangIdDataGridViewColumn
			//				
			this.uxNhomKhachHangIdDataGridViewColumn.DisplayMember = "KhachHangId";	
			this.uxNhomKhachHangIdDataGridViewColumn.ValueMember = "NhomKhachHangId";	
			this.uxNhomKhachHangIdDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxNhomKhachHangIdDataGridViewColumn.DataSource = uxNhomKhachHangIdBindingSource;				
				
			//
			// uxDieuKienGiamGiaIdDataGridViewColumn
			//				
			this.uxDieuKienGiamGiaIdDataGridViewColumn.DisplayMember = "DieuKienChung";	
			this.uxDieuKienGiamGiaIdDataGridViewColumn.ValueMember = "DieuKienId";	
			this.uxDieuKienGiamGiaIdDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxDieuKienGiamGiaIdDataGridViewColumn.DataSource = uxDieuKienGiamGiaIdBindingSource;				
				
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxChietKhauDataGridView);
			this.Name = "ChietKhauDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			//((System.ComponentModel.ISupportInitialize)(this.uxNhomKhachHangIdBindingSource)).EndInit();
			//((System.ComponentModel.ISupportInitialize)(this.uxDieuKienGiamGiaIdBindingSource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				ChietKhauDataGridViewEventArgs args = new ChietKhauDataGridViewEventArgs();
				args.ChietKhau = _currentChietKhau;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class ChietKhauDataGridViewEventArgs : System.EventArgs
		{
			private Entities.ChietKhau	_ChietKhau;
	
			/// <summary>
			/// the  Entities.ChietKhau instance.
			/// </summary>
			public Entities.ChietKhau ChietKhau
			{
				get { return _ChietKhau; }
				set { _ChietKhau = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxChietKhauDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnChietKhauDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxChietKhauDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnChietKhauDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxChietKhauDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxChietKhauIdDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].ChietKhauId;
						break;
					case "uxStartDateDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].StartDate;
						break;
					case "uxEndDateDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].EndDate;
						break;
					case "uxDieuKienGiamGiaIdDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].DieuKienGiamGiaId;
						break;
					case "uxGhiChuDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].GhiChu;
						break;
					case "uxLastUpdateDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].LastUpdate;
						break;
					case "uxUpdateByDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].UpdateBy;
						break;
					case "uxHeaderDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].Header;
						break;
					case "uxNhomKhachHangIdDataGridViewColumn":
						e.Value = ChietKhauList[e.RowIndex].NhomKhachHangId;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxChietKhauDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnChietKhauDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxChietKhauDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxChietKhauIdDataGridViewColumn":
						ChietKhauList[e.RowIndex].ChietKhauId = (System.Guid)e.Value;
						break;
					case "uxStartDateDataGridViewColumn":
						ChietKhauList[e.RowIndex].StartDate = (System.DateTime)e.Value;
						break;
					case "uxEndDateDataGridViewColumn":
						ChietKhauList[e.RowIndex].EndDate = (System.DateTime?)e.Value;
						break;
					case "uxDieuKienGiamGiaIdDataGridViewColumn":
						ChietKhauList[e.RowIndex].DieuKienGiamGiaId = (System.Guid?)e.Value;
						break;
					case "uxGhiChuDataGridViewColumn":
						ChietKhauList[e.RowIndex].GhiChu = (System.String)e.Value;
						break;
					case "uxLastUpdateDataGridViewColumn":
						ChietKhauList[e.RowIndex].LastUpdate = (System.DateTime)e.Value;
						break;
					case "uxUpdateByDataGridViewColumn":
						ChietKhauList[e.RowIndex].UpdateBy = (System.Int32)e.Value;
						break;
					case "uxHeaderDataGridViewColumn":
						ChietKhauList[e.RowIndex].Header = (System.String)e.Value;
						break;
					case "uxNhomKhachHangIdDataGridViewColumn":
						ChietKhauList[e.RowIndex].NhomKhachHangId = (System.Guid?)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
